import React,{useState,useContext} from "react"
import User from "./user"
import {UserContext} from "./testContext"

const App = (props)=>{
  const {state,dispatch} = useContext(UserContext);
  const handleClick = ()=>{
    dispatch({
      type:'LOGIN',
      payload:true
    })
  }
  return (
    <>
      {
        state.isLogin?<User></User> : <button onClick={handleClick}>登录</button>
      }
    </>
  )
}
export default App